package com.ruoyi.projects.controller;

import java.util.List;

import com.ruoyi.common.constant.BuConstants;
import com.ruoyi.common.core.domain.ApiResult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.projects.domain.AliSms;
import com.ruoyi.projects.service.IAliSmsService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 阿里短信Controller
 * 
 * @author ruoyi
 * @date 2022-01-06
 */
@RestController
@RequestMapping("/projects/AliSms")
public class AliSmsController extends BaseController
{
    @Autowired
    private IAliSmsService aliSmsService;

    /**
     * 查询阿里短信列表
     */
    @PreAuthorize("@ss.hasPermi('projects:AliSms:list')")
    @GetMapping("/list")
    public TableDataInfo list(AliSms aliSms)
    {
        startPage();
        List<AliSms> list = aliSmsService.selectAliSmsList(aliSms);
        return getDataTable(list);
    }

    /**
     * 获取阿里短信详细信息
     */
    @PreAuthorize("@ss.hasPermi('projects:AliSms:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(aliSmsService.selectAliSmsById(id));
    }

    /**
     * 修改阿里短信
     */
    @PreAuthorize("@ss.hasPermi('projects:AliSms:edit')")
    @Log(title = "阿里短信", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AliSms aliSms)
    {
        int i = aliSmsService.updateAliSms(aliSms);
        if (i>0){
            return AjaxResult.success();
        }
        return AjaxResult.success("修改失败");
    }


}
